from baseproxy.proxy import ReqIntercept, RspIntercept, AsyncMitmProxy

__author__ = 'qiye'
__date__ = '2018/6/21 23:35'

tager = {
    "www-pc44.com": "js/common.js"
}

class DebugInterceptor(RspIntercept):


    def deal_response(self, response):
        request=response.request
        path = tager.get(request.hostname)
        if path is not None and request.path.find(path)!=-1:
            with open("./pc.js",'rb') as f:
                response.set_body_data(f.read())
            print(response.get_body_data())
        return response



if __name__=="__main__":

    baseproxy = AsyncMitmProxy(server_addr=('0.0.0.0',8989),https=True)
    baseproxy.register(DebugInterceptor)
    baseproxy.serve_forever()